package com.catersystem.zmy.catersystem.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListView;

import com.catersystem.zmy.catersystem.R;
import com.catersystem.zmy.catersystem.adapter.TypeAdapter;
import com.catersystem.zmy.catersystem.base.BaseFragment;
import com.catersystem.zmy.catersystem.bean.TypeBean;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * 类别
 * Created by Administrator on 2017/12/13 0013.
 */

public class TypeFragment extends BaseFragment {
    @BindView(R.id.elv_dishes_type)
    ExpandableListView mElvDishesType;

    private List<TypeBean> mTypeBeanList;

    @Override
    protected View initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle
            savedInstanceState) {
        return inflater.inflate(R.layout.fragment_setting_type, container, false);
    }

    @Override
    protected void initView(View view) {
        setTypeBeanList();
        mElvDishesType.setAdapter(new TypeAdapter(activity,mTypeBeanList));
        int count = mElvDishesType.getCount();
        for (int i = 0; i < count; i++) {
            mElvDishesType.expandGroup(i);
        }
    }

    private void setTypeBeanList() {
        mTypeBeanList = new ArrayList<>();
        List<TypeBean.ChildType> mChildTypeList = new ArrayList<>();
        mChildTypeList.add(new TypeBean.ChildType("凉菜，热菜，酒水，粉面，麻辣烫，米饭"));
        mTypeBeanList.add(new TypeBean("主食",mChildTypeList));
        mTypeBeanList.add(new TypeBean("酒水",mChildTypeList));
        mTypeBeanList.add(new TypeBean("零食",mChildTypeList));
    }
}
